//
//  BDThirdPartService.m
//  BadBoy
//
//  Created by wen on 2017/3/10.
//  Copyright © 2017年 com.8xiong. All rights reserved.
//

#import "BDThirdPartService.h"
#import "UMSocialCore/UMSocialCore.h"
#import <WXApi.h>
#import <AMapFoundationKit/AMapFoundationKit.h>
#import <AMapLocationKit/AMapLocationKit.h>
#import "BDFMDBTool.h"
//#import "BDFridentInfo.h"
#import "BDBaseUserModel.h"
#import "BDLocationServer.h"
#import "BDApplyFriendsModel.h"

@implementation BDThirdPartService

+ (void)settingThird{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        //友盟
        //统计
        UMConfigInstance.appKey = @"593929a4a40fa36eab000b20";
        UMConfigInstance.channelId = @"App Store";
        [MobClick startWithConfigure:UMConfigInstance];//配置以上参数后调用此方法初始化SDK！

        
        //打开调试日志
        [[UMSocialManager defaultManager] openLog:NO];
        //设置友盟appkey
        [[UMSocialManager defaultManager] setUmSocialAppkey:@"593929a4a40fa36eab000b20"];
//        微博
//        [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_Sina appKey:@"1582910100" appSecret:@"8730555c338e55af35ce62a7344536c2" redirectURL:@"http://sns.whalecloud.com/sina2/callback"];
        
        //设置QQ互联的appID
        [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_QQ appKey:@"1105951370"/*设置QQ平台的appID*/  appSecret:nil redirectURL:@"http://www.nowfc.com"];

        //设置微信的appKey和appSecret
        [[UMSocialManager defaultManager] setPlaform:UMSocialPlatformType_WechatSession appKey:@"wx52064d18c1389f26" appSecret:@"9e1c043ab8a99bd7d34a39557bb8dfd4" redirectURL:@"http://www.nowfc.com"];
        
        [WXApi registerApp:@"wx52064d18c1389f26"];
        
        //高德地图
        [[AMapServices sharedServices] setEnableHTTPS:YES];
        [AMapServices sharedServices].apiKey = @"890819afd713cf90291758e78052e2ce";
        
   #pragma mark 初始化文件夹路径
        NSString *paths = [DocumentPath stringByAppendingPathComponent:@"temp"];
        
        if (![[NSFileManager defaultManager] fileExistsAtPath:paths]) {
            [[NSFileManager defaultManager] createDirectoryAtPath:paths withIntermediateDirectories:YES attributes:nil error:nil];
        }
        
        NSString *searchPaths = [DocumentPath stringByAppendingPathComponent:@"search.plist"];
        if (![[NSFileManager defaultManager] fileExistsAtPath:searchPaths]) {
            NSMutableArray *arr = [NSMutableArray array];
            BOOL reslt = [arr writeToFile:searchPaths atomically:YES];
//            // BDLog(ASLocalizedString(@"写入成功了么？%d"), reslt);
        }
//        // BDLog(ASLocalizedString(@"plist文件路径：%@"), searchPaths);
        
        NSString *homeSearchPaths = [DocumentPath stringByAppendingPathComponent:@"homeSearch.plist"];
        if (![[NSFileManager defaultManager] fileExistsAtPath:homeSearchPaths]) {
            NSMutableArray *arr = [NSMutableArray array];
            BOOL reslt = [arr writeToFile:homeSearchPaths atomically:YES];
//            // BDLog(ASLocalizedString(@"写入成功了么？%d"), reslt);
        }
//        // BDLog(ASLocalizedString(@"plist文件路径：%@"), homeSearchPaths);
        
        NSString *zhidingSearchPaths = [DocumentPath stringByAppendingPathComponent:@"zhidingSearch.plist"];
        if (![[NSFileManager defaultManager] fileExistsAtPath:zhidingSearchPaths]) {
            NSMutableArray *arr = [NSMutableArray array];
            BOOL reslt = [arr writeToFile:zhidingSearchPaths atomically:YES];
        }
        
        NSString *miandaraoSearchPaths = [DocumentPath stringByAppendingPathComponent:@"miandaraoSearch.plist"];
        if (![[NSFileManager defaultManager] fileExistsAtPath:miandaraoSearchPaths]) {
            NSMutableArray *arr = [NSMutableArray array];
            BOOL reslt = [arr writeToFile:miandaraoSearchPaths atomically:YES];
        }
        
        if (![[NSFileManager defaultManager] fileExistsAtPath:GroupRefrencePath]) {
            NSMutableArray *arr = [NSMutableArray array];
            BOOL reslt = [arr writeToFile:GroupRefrencePath atomically:YES];
        }
//        [BDFMDBTool creatWithClass:[BDFridentInfo class] tableName:FriendsTable_Name];
        [BDFMDBTool creatWithClass:[BDApplyFriendsModel class] tableName:ApplyFriendTable_Name];
        [BDFMDBTool creatWithClass:[BDBaseUserModel class] tableName:BaseUserTable primaryKey:@"user_id"];
        

        //开启定位
        [[BDLocationServer sharedServer] locate];
//        dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
//            
//        });
        
        
    });
}

@end
